package xio.ccf_201403;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * ccf 201403-2 窗口 100分
 * Created by Xio on 2017/11/7
 */
public class Window {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Rect> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new Rect(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(),i+1));
		}
		
		label:
		for (int i = 0; i < m; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			for (int j = n-1; j >= 0; j--) {
				Rect tmp = list.get(j);
				if (tmp.isClicked(x, y)) {
					System.out.println(tmp.id);
					//置于顶部
					list.remove(j);
					list.add(n-1,tmp);
					
					continue label;
				}
			}
			System.out.println("IGNORED");
		}
	}

	static class Rect {
		int x1, y1, x2, y2;
		int id;
		
		public Rect(int x1, int y1, int x2, int y2,int id) {
			this.x1 = x1;
			this.y1 = y1;
			this.x2 = x2;
			this.y2 = y2;
			this.id = id;
		}

		public boolean isClicked(int x, int y) {
			return (x >= x1 && x <= x2 && y >= y1 && y <= y2);

		}

	}

}
